package com.house.controller;

import com.house.pojo.HouseOrder;
import com.house.service.IHouseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/houseOrder")
/**
 * 22001011032刘晓妍
 */
public class HouseOrderController {
    @Autowired
    private IHouseOrderService service;
    @GetMapping
    public List<HouseOrder> list(){
        return service.list();
    }
    @GetMapping("/{id}")
    public HouseOrder getInfo(@PathVariable Integer id) {
        return service.getById(id);
    }
    @PostMapping
    public Integer add(@RequestBody HouseOrder houseOrder){
        if (houseOrder.getNo()==null){
            return 0;
        }
        return service.add(houseOrder);
    }
    @PutMapping
    public Integer update(@RequestBody HouseOrder houseOrder){
        return service.update(houseOrder);
    }
    @DeleteMapping("/{id}")
    public Integer delete(@PathVariable Integer id){
        return service.delete(id);
    }
}
